package com.ruoyi.iot.domain.dto;

import com.ruoyi.iot.domain.entity.DeviceAlarmWindow;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * 设备告警窗口导出 DTO
 */
@Data
public class DeviceAlarmWindowExportDTO {

    @Schema(description = "设备名称")
    private String deviceName;

    @Schema(description = "窗口开始时间")
    private LocalDateTime windowStart;

    @Schema(description = "窗口结束时间")
    private LocalDateTime windowEnd;

    @Schema(description = "聚合粒度（分钟）")
    private Integer granularityMinutes;

    @Schema(description = "速断动作次数")
    private Integer quickstrikeSum;

    @Schema(description = "过流保护动作次数")
    private Integer overcurrentSum;

    @Schema(description = "热保护动作次数")
    private Integer thermalSum;

    @Schema(description = "过压动作次数")
    private Integer overpressureSum;

    @Schema(description = "热保护预警次数")
    private Integer heatWarnSum;

    @Schema(description = "零序过流告警次数")
    private Integer zeroAlarmSum;

    @Schema(description = "过负荷预警次数")
    private Integer loadWarnSum;

    @Schema(description = "告警总次数")
    private Integer totalAlarmCount;

    @Schema(description = "故障总次数")
    private Integer totalFaultCount;

    @Schema(description = "监视模块告警次数")
    private Integer monitorModuleAlarmSum;

    @Schema(description = "光强越限告警次数")
    private Integer fiberPowerAlarmSum;

    @Schema(description = "过热保护告警次数")
    private Integer overTemperatureAlarmSum;

    @Schema(description = "过压告警次数")
    private Integer overVoltageAlarmSum;

    @Schema(description = "零序电压告警次数")
    private Integer zeroSeqVoltageAlarmSum;

    @Schema(description = "非电量告警次数1")
    private Integer nonElectrical1AlarmSum;

    @Schema(description = "非电量告警次数2")
    private Integer nonElectrical2AlarmSum;

    @Schema(description = "非电量告警次数3")
    private Integer nonElectrical3AlarmSum;

    @Schema(description = "控制电源故障次数")
    private Integer controlPowerFailSum;

    /**
     * 将实体转换为导出 DTO
     *
     * @param source 设备告警窗口实体
     * @param deviceName 设备名称
     * @return 导出 DTO
     */
    public static DeviceAlarmWindowExportDTO from(DeviceAlarmWindow source, String deviceName) {
        DeviceAlarmWindowExportDTO target = new DeviceAlarmWindowExportDTO();
        BeanUtils.copyProperties(source, target);
        target.setDeviceName(deviceName);
        return target;
    }
}
